package com.shengcheng.cunsumer;

import com.shengcheng.constant.KafkaConstant;
import com.shengcheng.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class SearchConsumer {
    @Autowired
    private SearchService searchService;

    //上架专辑
    @KafkaListener(topics = KafkaConstant.ONSALE_ALBUM_QUEUE)
    public void onSaleAlbum(Long albumId) {
        if (albumId != null) {
            searchService.onSaleAlbum(albumId);
        }
    }

    //下架专辑
    @KafkaListener(topics = KafkaConstant.OFFSALE_ALBUM_QUEUE)
    public void offSaleAlbum(Long albumId) {
        if (albumId != null) {
            searchService.offSaleAlbum(albumId);
        }
    }
}
